<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Genre</title>
<link rel="stylesheet" type="text/css" href="../CSS/CSS.css" />
<link rel="stylesheet" type="text/css" href="../CSS/header.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
if (!window.jQuery) {
    document.write('<script src="../Javascript/jQuery 1.9.1.js"><\/script>');
}
</script>
<script src="../Javascript/Popups.js"></script>
<script>
	function Back(){
        window.history.back();
    }
</script>
</head>
<body>

<?php include_once 'admin_check.php'?>
<?php include_once('database.php'); ?>
<?php include_once 'header.php' ?>
<div id='page_content'>	
	<h1>Ændre genre navn:</h1>
	<?php
		include_once('session_start.php');
		include_once('get_message.php');		
	?>
	<form action="edit_genre_db.php?action=create" method="post"> 
		<table border="1"  id="create_genre_table">   
	        <tr>
	        	<td>Opret nye genre:</td>
			</tr>
	        <tr>
	        	<td>
	            	<input type="text" name="GenreName[]" maxlength="20" />
				</td>
	 		</tr> 
	        <tr>
	        	<td>       
				    <input type="submit" class="submit" value="Opret genre" />
				</td>
			</tr>           
		</table>
	</form>
    <form action="edit_genre_db.php?action=edit" method="post" id="genre_form">
        <table border="1" id="genre">
            <?php 
                $query = "SELECT * FROM genre";                
                $stmt = $db -> query($query);
        
                while($result = $stmt->fetch_assoc()){
                    echo'<tr id="genre_'.$result["GenreId"].'">
                            <td>
                                <input type="hidden" id="genre_'.$result["GenreId"].'_id" name="GenreId[]" value="'.$result["GenreId"].'">
                                <input type="text" id="genre_'.$result["GenreId"].'_name" name="GenreName[]" value="'.$result["GenreName"].'">
                            </td>
                            <td>
                                <a href="edit_genre_db.php?action=delete&id='.$result["GenreId"].'" class="delete" cfm_href="edit_genre_db.php?action=delete&id='.$result["GenreId"].'">Slet</a>
                            </td>
                        </tr>';     
                }
                if($stmt->num_rows > 0){
                    echo'<tr>
                            <td>
                                <input type="submit" class="submit" value="Rediger Genre">
                            </td>
                        </tr>';
                }
            ?>
        </table>
    </form>	
</div>
<?php
    include_once('footer.php');
    ?>
</body>
</html>